import os
from dotenv import load_dotenv, find_dotenv
from typing import List, ClassVar

from pydantic import BaseModel, ConfigDict


class Config(BaseModel):
    # 加载环境变量
    load_dotenv(find_dotenv(), override=True)
    # 调试模式
    APP_DEBUG: bool = True
    # 项目信息
    VERSION: str = "0.0.1"
    PROJECT_NAME: str = "fasdapi"
    DESCRIPTION: str = '<a href="/redoc" target="_blank">redoc</a>'
    # 静态资源目录
    STATIC_DIR: str = os.path.join(os.getcwd(), "storage")
    TEMPLATE_DIR: str = os.path.join(STATIC_DIR, "templates")
    BASE_URL: str = 'http://0.0.0.0:10182'
    # 跨域请求
    CORS_ORIGINS: List = ["*"]
    CORS_ALLOW_CREDENTIALS: bool = True
    CORS_ALLOW_METHODS: List = ["*"]
    CORS_ALLOW_HEADERS: List = ["*"]
    # Session
    SECRET_KEY: ClassVar[str] = 'session'
    SESSION_COOKIE: str = 'session_id'
    SESSION_MAX_AGE: int = 1209600
    # 其他字段...
    # Jwt
    JWT_SECRET_KEY: str = "a8239a8ccf8aa53cf9642c51ffcde2f2bb384d88e6622aa6d486eae62a7ed147"
    JWT_ALGORITHM: str = "HS256"
    JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 7 * 60

    SWAGGER_UI_OAUTH2_REDIRECT_URL: str = "/api/v1/test/oath2"
    # 订单状态待任务时间
    ORDER_TASK_TIME: int = 1

    # 二维码过期时间
    QRCODE_EXPIRE: int = 60 * 1

    # # 微信配置
    # official_account = {
    #     "appid": os.getenv("wechat_official_account_appid"),
    #     "secret": os.getenv("wechat_official_account_secret"),
    # }
    model_config = ConfigDict(arbitrary_types_allowed=True)


settings = Config()
